package com.pet.user.controller;


import com.pet.common.domain.Result;
import com.pet.user.domain.po.Membership;
import com.pet.user.service.IMembershipService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 会员积分等级表 前端控制器
 * </p>
 *
 * @author Cookies
 * @since 2024-07-03
 */
@Api(tags = "会员积分等级服务接口")
@RestController
@RequestMapping("/memberships")
@RequiredArgsConstructor
public class MembershipController {
    private final IMembershipService membershipService;

    @GetMapping("/list")
    @ApiOperation("查询会员积分等级列表")
    public Result queryMembershipList() {
        List<Membership> membershipList = membershipService.queryMembershipList();
        return membershipList.isEmpty() ? Result.error("会员业务繁忙，请稍后重试...") : Result.success(membershipList);
    }

    @GetMapping("/discount")
    @ApiOperation("查询会员折扣信息")
    public Integer queryDiscountByUser() {
        return membershipService.queryDiscountByUser();
    }
}
